package com.example.administrator.caigou51.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.global.Constant;
import com.example.administrator.caigou51.util.ToastUtil;
import com.example.administrator.caigou51.widget.web.Html5Webview;

/**
 * Created by Administrator on 2016/9/3/003.
 */
public class WebHtmlActivity extends GBaseActivity {
    Html5Webview mWebView;
    public static final String WebUrl = "WebUrl";
    public static final String Title = "Title";
    public static final String RightText = "RightText";
    public static final String IsNeedShare = "isNeedShare";// 转发用
    public static final String NoEdit = "NoEdit";// 禁止编辑
    public static final String upLoadPreviewHtml5 = "upLoadPreviewHtml5";// 预览完成upLoadPreviewHtml5用
    public static final String activityID = "activityID";// 预览完成upLoadPreviewHtml5用,更改活动ID
    public static final String IsCoolAct = "IsCoolAct";// IsCoolAct
    public static final String IsBrandTrain = "IsBrandTrain";// IsCoolAct
    private boolean isCoolAct;
    private boolean isBrandTrain;
    public String isNeedShare;
    public String noEdit;
    public String activityId;
    protected String url;
    private boolean isTaskDoing=false;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mWebView = new Html5Webview(this);
        String title = getIntent().getStringExtra(Title);
        String rightTest = getIntent().getStringExtra(RightText);
        String weburl = getIntent().getStringExtra(WebUrl);
        isCoolAct = getIntent().getBooleanExtra(IsCoolAct,false);
        isBrandTrain = getIntent().getBooleanExtra(IsBrandTrain,false);
        activityId = getIntent().getStringExtra(activityID);
        isNeedShare = getIntent().getStringExtra(IsNeedShare);
        noEdit = getIntent().getStringExtra(NoEdit);
        if (!TextUtils.isEmpty(weburl)) {
            url = weburl;
        }
        setTopTitle(title);
        if (!TextUtils.isEmpty(rightTest)) {
            setRightText(View.VISIBLE, rightTest);
        }
        if (savedInstanceState != null) {
            mWebView.restoreState(savedInstanceState);
        } else {
            if (url != null) {

	/*			Map<String,String> header=new HashMap<>();
				header.put("Connection","keep-alive");
				header.put(Constant.SystemContext.TOKEN,AppConfig.getInstance().getToken());
				header.put("Cookie",Constant.SystemContext.Cookie);*/
/*
                CookieSyncManager.createInstance(this);
                CookieManager cookieManager = CookieManager.getInstance();
                cookieManager.setAcceptCookie(true);
                cookieManager.removeSessionCookie();//移除
                cookieManager.setCookie(Constant.SystemContext.ROOT_URL_VALUE, AppConfig.getInstance().getCookie());//cookies是在HttpClient中获得的cookie
                CookieSyncManager.getInstance().sync();*/
                //http://gmall.legacy.hk/gmall/create/fewwords/fewwords.jsp?activityid=998753397
                //mWebView.loadUrl("http://gmall.legacy.hk/gmall/create/fewwords/fewwords.jsp?activityid=998753397");
                mWebView.loadUrl(url);

            }
        }
        setContentView(mWebView.getLayout());
        // 转发判断
		/*if (!TextUtils.isEmpty(isNeedShare)) {
			setRightImg(View.VISIBLE, R.drawable.selector_share);
		}*/
      /*  if (!TextUtils.isEmpty(noEdit)) {

            initForeShowDialog(R.string.add_add_praise,"知道了",TeamManageDialog.zsdjzh);

        }
        mWebView.addJavascriptInterface(new CallJs(), "robot");*/
    }



    @Override
    protected void onPause() {
        super.onPause();

    }


}
